﻿<?php

class Add_check extends CI_Controller{

	function __construct(){
		parent::__construct();
		 header("Content-type: text/html; charset=gbk");
		$this->load->model('w3a_admin');	
		$this->load->model("w3a_admin");
	}
	

	//修改文章
	function edit_article($art_id){
		$data['news_title'] = $this->input->post('news_title')?$this->input->post('news_title'):null;
		$data['news_content'] = $this->input->post('news_content')?$this->input->post('news_content'):null;
		$data['news_parent_id'] = $this->input->post('news_parent_id')?$this->input->post('news_parent_id'):null;
		
		$rows = $this->w3a_admin->edit_article($data);
		if($rows == true){
			echo '修改成功';
		}else{
			echo '修改失败';
		}
	}
	//添加文章
	function add_article(){
		$data['news_title'] = $this->input->post('news_title')?$this->input->post('news_title'):null;
		$data['news_content'] = $this->input->post('news_content')?$this->input->post('news_content'):null;
		$data['news_parent_id'] = $this->input->post('news_parent_id')?$this->input->post('news_parent_id'):null;

		if(($data['news_title'] == null) || ($data['news_content'] == null)){
			echo '每一项都必须填写';
			exit;
		}
		$res = $this->w3a_admin->add_article($data);
		if($res == true){
			echo '添加成功';
		}else{
			echo '添加失败';
		}
	} 

	//添加分类
	function add_category(){
		$data['w3a_type']  = $this->input->post('w3a_type')?$this->input->post('w3a_type'):null;
		if($data['w3a_type'] == null){
			echo '请填写分类名称';
			exit;
		}

		$res = $this->w3a_admin->add_category($data);
		if($res == true ){
			echo '添加成功';
		}else{
			echo '添加失败';
		}
	}
	//修改信息
	function edit_mes(){
		$data['index_logo'] = $this->input->post('index_logo')?$this->input->post('index_logo'):null;
		$data['index_name'] = $this->input->post('index_name')?$this->input->post('index_name'):null;
		$data['index_desc'] = $this->input->post('index_desc')?$this->input->post('index_desc'):null;
		$data['keyword'] = $this->input->post('keyword')?$this->input->post('keyword'):null;
		$data['index_gov'] = $this->input->post('index_gov')?$this->input->post('index_gov'):null;
		$data['index_tel'] = $this->input->post('index_tel')?$this->input->post('index_tel'):null;
		foreach($data as $v){
			if($v = null){
				echo $v.'不能为空';
			}
		}
		$res = $this->w3a_admin->update_mes($data);
		if($res == 1){
			echo '添加成功';
		}else{
			echo '添加失败';
		}
	}
		//删除文章
	function del_article($art_id){
		$res = $this->w3a_admin->del_article($art_id);
		if($res == 1){
			echo '删除成功,如果要恢复请到回收站恢复！';
		}else{
			echo '不知道为什么失败了。';
		}
	}
	//恢复文章
	function recover($art_id){
		$res = $this->w3a_admin->remove($art_id);

		if($res == 1){
			echo '恢复成功';
		}else{
			echo '不知道为什么失败了。';
		}
	}
	function del_article_long_time(){
		$res = $this->w3a_admin->del_article_long_time();

		if($res == 1){
			echo '恢复成功';
		}else{
			echo '不知道为什么失败了。';
		}
	}
}


?>